﻿Public Partial Class WebForm2
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim table As New DataTable("childTable")
        Dim column As DataColumn
        Dim row As DataRow
        ' Create first column and add to the DataTable.
        column = New DataColumn()
        column.DataType = System.Type.GetType("System.Int32")
        column.ColumnName = "ChildID"
        column.AutoIncrement = True
        column.Caption = "ID"
        column.ReadOnly = True
        column.Unique = True

        ' Add the column to the DataColumnCollection.
        table.Columns.Add(column)

        ' Create second column.
        column = New DataColumn()
        column.DataType = System.Type.GetType("System.String")
        column.ColumnName = "ChildItem"
        column.AutoIncrement = False
        column.Caption = "ChildItem"
        column.ReadOnly = False
        column.Unique = False
        table.Columns.Add(column)

        ' Create third column.
        column = New DataColumn()
        column.DataType = System.Type.GetType("System.Int32")
        column.ColumnName = "ParentID"
        column.AutoIncrement = False
        column.Caption = "ParentID"
        column.ReadOnly = False
        column.Unique = False
        table.Columns.Add(column)

        Dim i As Integer
        For i = 0 To 4
            row = table.NewRow()
            row("childID") = i
            row("ChildItem") = "Item " + i.ToString()
            row("ParentID") = 0
            table.Rows.Add(row)
        Next i
        GridView1.DataSource = table
        GridView1.DataBind()
        Session.Add("haha", table)
    End Sub
End Class